#include "ScrollerItem.h"

#include <QPainter>
#include <QGraphicsTextItem>

ScrollerItem::ScrollerItem(int index, QGraphicsItem* parent)
    : QGraphicsItem(parent), m_code(index)
{
    m_color = QColor(qrand()%255, qrand()%255, qrand()%255);
}

QRectF ScrollerItem::boundingRect() const
{
    return QRectF(0,0,360,80);
}

void ScrollerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    painter->setPen(Qt::black);
    painter->setBrush(m_color);

    painter->drawRect(boundingRect());

    QString text("Item: " + QString::number(m_code));
    painter->drawText(boundingRect(), Qt::AlignCenter, text);
}

